<template>
  <div>

  <el-table
      ref="filterTable"
      :data="tableData"
      border
      style="width: 100%"
      :default-sort = "{prop: 'date', order: 'descending'}">
    <el-table-column
        prop="eid"
        label="考试编号"
        width="180">
    </el-table-column>
    <el-table-column
        prop="ename"
        label="考试科目"
        width="180">
    </el-table-column>

    <el-table-column
        prop="roomVo.rname"
        label="班级"
        width="100"
        :filters="[{ text: '2306A', value: '2306A' }, { text: '2306B', value: '2306B' }, { text: '2307A', value: '2307A' }, { text: '2308A', value: '2308A' }]"
        :filter-method="filterTag"
        filter-placement="bottom-end">
      <template slot-scope="scope">
        <el-tag
            disable-transitions>{{scope.row.roomVo.rname}}</el-tag>
      </template>
    </el-table-column>
    <el-table-column
        prop="opentime"
        label="开始时间"
        width="180">
    </el-table-column>

    <el-table-column
        prop="closetime"
        label="关闭时间"
        width="180">
    </el-table-column>

    <el-table-column>
      <template slot-scope="scope">
      <el-button class="btn" type="primary" @click="doq(scope.row.eid)">答卷</el-button>
      </template>
    </el-table-column>
  </el-table>
  </div>
</template>

<script>
import axios from "axios";
import {getRequest} from "@/utils/api";

export default {
  name: "exams",
  data(){
    return{
      tableData:[]
    }
  },
  methods:{
    doq(obj){
      window.sessionStorage.setItem("eid",JSON.stringify(obj));
      this.$router.push("/doque");
    },
    findtea(){
      getRequest("/student/exams").then(resp =>{
        this.tableData=resp.data.data;
      })
    },
    filterTag(value, row) {
      return row.roomVo.rname == value;
    },
  },
  created() {
    this.findtea();
  }
}
</script>

<style scoped>

</style>